"""扫描任务Repository"""
from typing import Optional, List
from sqlalchemy.orm import Session
from app.models.scan_task import ScanTask
from app.repositories.base import BaseRepository


class ScanTaskRepository(BaseRepository[ScanTask]):
    """扫描任务数据访问层"""

    def __init__(self, db: Session):
        super().__init__(ScanTask, db)

    def get_by_task_type(self, task_type: str) -> Optional[ScanTask]:
        """根据任务类型获取任务"""
        return self.get_by_field("task_type", task_type)

    def get_enabled_tasks(self) -> List[ScanTask]:
        """获取所有启用的任务"""
        return self.get_all(filters={"status": "enabled"})

